package com.situ.ssm.util;

// JSON鏍煎紡鐨勯�氱敤鍝嶅簲瀵硅薄锛屽皝瑁呯殑灏辨槸鍚庡彴杩斿洖缁欏墠鍙扮殑鎵�鏈変俊鎭�
public class JSONResult {
	public static final int ERROR = 1;
	public static final int OK = 0;
	public static final int NOT_LOGIN = 2;

	// 褰撳墠鐘舵�侊紙绋嬪簭鍛樺垽鏂姸鎬侊級:鎴愬姛銆佸け璐ャ�佹湭鐧诲綍銆佹病鏈夋潈闄�
	// 褰撳墠鐧诲綍鏄垚鍔熻繕鏄け璐ヨ鍛婅瘔鍓嶅彴锛屽墠鍙版墠鑳界煡閬撳脊鍑虹殑鎻愮ず妗嗙敤errorMsg銆乷kMsg
	private Integer code;
	// 鎻忚堪淇℃伅锛堜富瑕佹槸缁欑敤鎴风湅鐨勬彁绀轰俊鎭級
	private String msg;
	// 鍚庡彴杩斿洖缁欏墠绔殑鏁版嵁 Object锛� User銆丩ist<User>
	private Object data;
	
//	public boolean isOk() {
//		return code == OK;
//	}

	public JSONResult() {
	}
	
	public JSONResult(Integer code) {
		this.code = code;
	}

	public JSONResult(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public JSONResult(Integer code, Object data) {
		this.code = code;
		this.data = data;
	}

	public JSONResult(Integer code, String msg, Object data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode
	public static JSONResult ok() {
		return new JSONResult(OK);
	}
	
	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode銆乵sg
	public static JSONResult ok(String msg) {
		return new JSONResult(OK, msg);
	}
	
	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode銆乨ata
	public static JSONResult ok(Object data) {
		return new JSONResult(OK, data);
	}
	
	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode銆乵sg銆乨ata
	public static JSONResult ok(String msg, Object data) {
		return new JSONResult(OK, msg, data);
	}
	

	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode
	public static JSONResult error() {
		return new JSONResult(ERROR);
	}
	
	// 鍛婅瘔鍓嶅彴鎴愬姛锛歝ode銆乵sg
	public static JSONResult error(String msg) {
		return new JSONResult(ERROR, msg);
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
}
